package mapper.kullanici;

import java.util.ArrayList;

import dbDrivers.ldapConnection;

import mapper.dbinterface;
import mapper.iMapper;
import mapper.duyuru.db2MapperDuyuru;
import mapper.duyuru.mySqlMapperDuyuru;

public class kullaniciMapper implements iMapper{
	private dbinterface DataBases;
	private dbinterface DataBases2;
	public kullaniciMapper() {
		config.Config.maine();
		if (config.Config.prop.getProperty("server.auth").toLowerCase() == "mysql"){
			if (DataBases == null){
				DataBases = (dbinterface) new mySqlMapperKullanici();
			}
		}
		else if(config.Config.prop.getProperty("server.auth").toLowerCase() == "db2"){
			if (DataBases == null){
				DataBases = (dbinterface) new db2MapperKullanici();
			}	
		}else{
			if(DataBases == null){
				DataBases2 = (dbinterface) new db2MapperKullanici();
				DataBases = (dbinterface) new ldapConnection();
			}
		}
		// TODO Auto-generated constructor stub
	}
	public boolean delete(Object oid) {
		// TODO Auto-generated method stub
		return DataBases.DataBaseDeleteObject(oid);
	}

	public ArrayList<Object> get(Object oid) {
		// TODO Auto-generated method stub
		return (ArrayList) DataBases.DataBaseGetObject(oid);
		
	}

	@Override
	public boolean put(Object oid) {
		// TODO Auto-generated method stub
		if(config.Config.prop.getProperty("server.auth").toLowerCase() == "ldap"){
			if (DataBases2.DataBasePut(oid)){
				//DataBases2
			}
		}
		return DataBases.DataBasePut(oid);
	}

	@Override
	public boolean update(Object oid) {
		// TODO Auto-generated method stubs
		if(config.Config.prop.getProperty("server.auth").toLowerCase() == "ldap"){
			
		}
		return DataBases.DataBaseUpdate(oid);
	}

}
